package com.hzqx.syndata.cron;

import com.hzqx.syndata.falsedemo.domain.Flm;
import com.hzqx.syndata.falsedemo.service.TestCacheService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate;

import java.util.ArrayList;
import java.util.List;

@Slf4j
@Component
public class TestVarCache {

    @Autowired
    private TestCacheService testCacheService;
    @Value("${flm.code}")
    private String[] code;
    @Value("${flm.color}")
    private String[] color;

   // @Scheduled(cron = "10 0/20 * * * ? ")
    public void scheduleMessage() {
        long startTime = System.currentTimeMillis();
        testCacheService.getDataCompany();
        for (int i = 0; i <code.length ; i++) {
            testCacheService.getData(code[i]);
            for (int j = 0; j < color.length; j++) {
                testCacheService.getDeatail(code[i],color[j]);
            }
        }
        long endTime = System.currentTimeMillis();
        long spendTime = (endTime-startTime)/1000;
        log.info("spendTime:"+spendTime);

    }
    //@Scheduled(cron = "10 * * * * ? ")
    public void scheduleMessage1() {
        for (int i = 0; i < code.length; i++) {
            testCacheService.getww();
        }
    }
}
